import {useState} from "react";

const TodoHeader = ({dispatch})=>{
    const [inputValue,setInputValue] = useState('')
    const onChange = (e)=>{
        setInputValue(e.target.value)
    }

    const onClick = ()=>{
        dispatch({
            type:'add_todo',
            todoMsg:inputValue
        })
    }
    return (
        <>
            <div className="flex-small">
                <input className="full-container" type='text' value={inputValue} onChange={onChange}/>
                <button onClick={onClick}>添加</button>
            </div>
        </>
    )
}

export default TodoHeader